import store from '@/store'

// 倒计时
export default (time) => {
  return new Promise((resolve, reject) => {
    if (time) {
      store.commit('common/set_timer', () => {
        if (time === 0) {
          clearInterval(store.state.common.timer)
          store.commit('common/set_countDownText', '获取验证码')
        } else {
          time--
          store.commit('common/set_countDownText', time + 's')
        }
      })
    }
  })
}
